package com.otherTest.bigdecimal;


import org.junit.Test;

import java.math.BigDecimal;

/**
 * @Description:
 * @author: conceit
 * @Date: 2018/9/515:55
 */
public class BigDecimalTest {

    @Test
    public void doTest() {

        BigDecimal bigDecimal = new BigDecimal("0.03");
        System.out.println(bigDecimal.subtract(new BigDecimal("0.01")).toPlainString());
        System.out.println(bigDecimal.subtract(new BigDecimal("0.01")).setScale(8, BigDecimal.ROUND_DOWN).toPlainString());
        System.out.println(bigDecimal.subtract(new BigDecimal("0.11111111111")).setScale(8, BigDecimal.ROUND_UP).toPlainString());
        System.out.println(bigDecimal.subtract(new BigDecimal("0.11111111111")).setScale(8, BigDecimal.ROUND_HALF_UP).toPlainString());
        System.out.println(bigDecimal.subtract(new BigDecimal("0.11111111111")).setScale(8, BigDecimal.ROUND_HALF_DOWN).toPlainString());
        System.out.println(bigDecimal.subtract(new BigDecimal("0.11111111111")).setScale(8, BigDecimal.ROUND_HALF_EVEN).toPlainString());

        System.out.println(bigDecimal.subtract(new BigDecimal("0.11111111111")).setScale(8, BigDecimal.ROUND_CEILING).toPlainString());
        System.out.println(bigDecimal.subtract(new BigDecimal("0.11111111111")).setScale(8, BigDecimal.ROUND_FLOOR).toPlainString());
        //System.out.println(bigDecimal.subtract(new BigDecimal("0.11111111111")).setScale(10,BigDecimal.ROUND_UNNECESSARY).toPlainString());


    }
}
